#include <vector>
#include <iostream>
#include <string>
#include <sstream>

std::vector<std::string> split(const std::string &s, char delim) {
    std::vector<std::string> result;
    std::stringstream ss(s);
    std::string item;

    while (std::getline(ss, item, delim)) {
        result.push_back(item);
    }

    return result;
}


std::vector<int> Str2IntList(std::string &str) {
    std::vector<std::string> vec = split(str, ',');
    std::vector<int> res{};
    for (const auto &num: vec) {
        auto nums = split(num, '-');
        if (nums.size() == 1) {
            res.push_back(std::atoi(num.c_str()));
            continue;
        }
        if (nums.size() == 2) {
            if (nums[0] == "") {
                res.push_back(std::atoi(num.c_str()));
                continue;
            }
            for (int k = std::atoi(nums[0].data()); k <= std::atoi(nums[1].c_str()); k++) {
                res.push_back(k);
            }

        }
    }
    return res;
}

int main() {
    std::string str = "1,3-7,-10,11- 15";
    std::vector<int> v1 = Str2IntList(str);
    for (const auto &i: v1) {
        std::cout << i << std::endl;
    }
    std::cout << "=====" << std::endl;
    std::string str1 = "";
    std::vector<int> v2 = Str2IntList(str1);
    for (const auto &i: v2) {
        std::cout << i << std::endl;
    }
    std::cout << "=====" << std::endl;
    return 0;
}

